<template>
  <div class="informationOverview">
    <div class="informationOverview-info">
      <customerInfo :type="type" :info="info" :customerName="customerName" />
    </div>
    <div class="header-title" v-if="type === '2'">
      <i></i><span>相关产品户</span>
    </div>
    <div class="right" v-if="type === '2'">
      <div class="tableBox">
        <el-table :data="tableData" class="tableBoxChild">
          <el-table-column
            prop="fundFullName"
            label="产品户名称"
            align="center"
            width="130"
          >
            <template slot-scope="scope">
              <span class="blue" @click="toProCustDetail(scope.row)">{{
                scope.row.fundFullName
              }}</span>
            </template>
          </el-table-column>
          <el-table-column
            prop="assetCode"
            label="基金代码"
            align="center"
            width="120"
          >
            <template slot-scope="scope">
              <span>{{ scope.row.assetCode || '--' }}</span>
            </template>
          </el-table-column>
          <el-table-column
            prop="fundEstablishDate"
            label="基金成立日期"
            align="center"
          >
            <template slot-scope="scope">
              <span>{{ scope.row.fundEstablishDate || '--' }}</span>
            </template>
          </el-table-column>
          <el-table-column
            prop="contribute_order"
            label="单位净值"
            align="center"
          >
            <template slot-scope="scope">
              <span>{{ scope.row.contribute_order || '--' }}</span>
            </template>
          </el-table-column>
          <el-table-column
            prop="latestAmount"
            label="最新规模(亿)"
            align="center"
          >
            <template slot-scope="scope">
              <span>{{ scope.row.latestAmount || '--' }}</span>
            </template>
          </el-table-column>
          <el-table-column
            prop="fundManagerName"
            label="基金经理"
            align="center"
            width="120"
          >
            <template slot-scope="scope">
              <span>{{ scope.row.fundManagerName || '--' }}</span>
            </template>
          </el-table-column>
          <el-table-column
            prop="totalCredit"
            label="授信总额(万)"
            align="center"
          >
            <template slot-scope="scope">
              <span>{{ scope.row.totalCredit || '--' }}</span>
            </template>
          </el-table-column>
          <el-table-column
            prop="restCredit"
            label="剩余额度(万)"
            align="center"
          >
            <template slot-scope="scope">
              <span>{{ scope.row.restCredit || '--' }}</span>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination
          background
          layout="prev, pager, next"
          :total="total"
          @current-change="pageFn"
        >
        </el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
import customerInfo from './customerInfo.vue';
import { GetQueryViewApi } from '../../../../api/customerManagement/informationOverview.js';
export default {
  components: {
    customerInfo,
  },
  props: {
    type: {
      type: String | Number,
    },
    customerId: {
      type: String,
    },
    customerName: {
      type: String,
    },
  },
  watch: {
    customerId: {
      handler(val) {
        if (val) {
          console.log(val);
          this.loadData();
        }
      },
      immediate: true,
    },
  },
  data() {
    return {
      dialogVisible: false,
      dealStatus: [],
      tableData: [],
      total: 10,
      info: {},
    };
  },
  created() {},
  mounted() {
    console.log(this.type);
  },
  methods: {
    async loadData() {
      const params = {
        customerId: this.customerId,
        // customerId: 'test02'
      };
      const { data } = await GetQueryViewApi(
        `hermes/${
          this.type === '2' ? 'customer' : 'product'
        }/baseInfo/queryView`,
        params
      );
      this.info = data;
      if (this.type === '2') {
        this.tableData = data.productList ? data.productList : [];
        this.total = data.productList ? data.productList.length : 0;
      }

      console.log(data);
    },
    toProCustDetail(row) {
      this.$router.push({
        path: '/customerManagement/customerView',
        query: {
          // type: this.type,
          type: '1',
          customerId: row.assetCode,
          // customerId: 'test02',
          customerName: this.customerName,
        },
      });
    },
    pageFn() {},
  },
};
</script>
<style lang="scss" scoped>
.el-table ::v-deep th.el-table__cell {
  background-color: #1c2238 !important;
  color: #fff;
}

.informationOverview {
  // width: 1400px;
  background-color: #1b2238;
  height: calc(100vh - 160px);
  overflow: scroll;
  .header-title {
    width: 100%;
    background: #1b2238;
    line-height: 50px;
    padding-left: 20px;
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    > i {
      width: 5px;
      height: 18px;
      display: block;
      background: #08b0f0;
    }
    > span {
      font-size: 12px;
      color: #ffffff;
      margin-left: 5px;
    }
  }
  .topBar {
    min-height: 80px;
    background-color: #262d47;
    padding: 20px;
    padding-left: 16px;
    padding-bottom: 0px;
  }

  .topBox {
    span {
      display: inline-block;
    }

    .searchBtn {
      margin-left: 20px;
    }

    .zj {
      margin-left: 20px;
    }

    .khTitle {
      height: 30px;
      line-height: 30px;
      vertical-align: top;
      color: #ffffff;
      font-size: 14px;
      font-weight: 700px;
      margin-right: 10px;
    }

    .khInput,
    .zjInput {
      height: 30px;
      line-height: 30px;
      width: 200px;
      overflow: hidden;
      border: 1px solid rgba(126, 163, 255, 0.3);
      color: #ffffff;
      background-color: #363657;
      border-radius: 3px;
      cursor: pointer;
      text-align: center;
      line-height: 30px;
      padding: 0px 10px;
      font-size: 12px;
      white-space: nowrap;
      text-overflow: ellipsis;
    }

    .zjTitle {
      height: 30px;
      line-height: 30px;
      vertical-align: top;
      color: #ffffff;
      font-size: 14px;
      font-weight: 700px;
      margin-right: 10px;
    }
  }

  .left {
    width: 240px;
    background-color: #262d47;
    height: 100%;
  }

  .right {
    flex: 1;
    height: 88%;
    display: flex;
    flex-direction: column;
  }

  .searchList {
    padding-top: 10px;
    padding-left: 10px;
    padding-right: 10px;
    height: 700px;
    overflow: scroll;

    .searchListItem {
      height: 35px;
      line-height: 35px;
      text-align: center;
      color: #959fc5;
      font-size: 12px;
      overflow: hidden; //超出隐藏
      white-space: nowrap; //不折行
      text-overflow: ellipsis; //溢出显示省略号
    }

    .searchListItem:hover {
      background: #1f9bfd !important;
      color: #fff;
      cursor: pointer;
    }
  }

  .searchListItemAct {
    background: #1f9bfd !important;
    color: #fff !important;
  }

  .bondCard {
    background-color: #262d47;
    color: #ffffff;
    margin-bottom: 10px;

    .info {
      display: flex;
      padding: 15px 20px;

      .infoItem {
        flex: 1;
      }
    }

    .infoItemLabel {
      margin-right: 30px;
      font-size: 14px;
    }

    .infoItemVal {
      font-size: 14px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #d6dcff;
    }
  }

  .el-table ::v-deep th.el-table__cell {
    background-color: #1c2238 !important;
    color: #fff;
  }

  .tableBox {
    background-color: #262d47;
    flex: 1;
    padding: 15px 10px;
    .blue {
      color: #6794df;
      cursor: pointer;
    }
    // width: 1426px;
  }

  .tableBoxChild {
    min-height: 500px;
  }

  .el-pagination {
    text-align: right;
  }

  .leftTitle {
    height: 40px;
    line-height: 40px;
    background: #354060;
    font-size: 14px;
    font-family: PingFang-SC-Bold, PingFang-SC;
    font-weight: bold;
    color: #ffffff;
    padding-left: 17px;
    margin-bottom: 10px;
  }

  .customersCardTitle {
    height: 40px;
    background: #354060;
    font-size: 14px;
    font-family: PingFang-SC-Bold, PingFang-SC;
    font-weight: bold;
    color: #ffffff;
    padding: 10px 16px;
  }
}
.operator {
  color: #1f9bfd;
  margin-right: 8px;
  cursor: pointer;
}
::v-deep {
  .el-dialog {
    border-top: 4px solid rgba($color: #1f9bfd, $alpha: 0.9);
    .el-dialog__header {
      border-bottom: 1px solid rgba(126, 163, 255, 0.3);
      padding: 0;
      height: 49px;
      line-height: 49px;
      padding-left: 16px;
    }
    .el-dialog__footer {
      border-top: 1px solid rgba(126, 163, 255, 0.3);
    }
  }
}
</style>
